using UnityEngine;

public class Referee : Instance<Referee>
{
	public StateMachine<Referee> stateMachine;

	public Transform trans_ball;

	private new void Awake()
	{
		base.Awake();
		stateMachine = new StateMachine<Referee>(this);
	}

	private void FixedUpdate()
	{
		stateMachine.fixedUpdate();
	}

	public bool isInState(State<Referee> state)
	{
		return stateMachine.isInState(state);
	}

	public void changeState(State<Referee> state)
	{
		if (!isInState(state))
		{
			stateMachine.changeState(state);
		}
	}

	public void do_opening()
	{
		changeState(RefereeStateOpening.getInstance());
	}

	public void do_jumpball()
	{
		changeState(RefereeStateJumpBall.getInstance());
	}

	public void do_playing()
	{
		changeState(RefereeStatePlaying.getInstance());
	}

	public void do_whistle()
	{
		changeState(RefereeStateWhistle.getInstance());
	}

	public void do_freethrow()
	{
		changeState(RefereeStateFreeThrow.getInstance());
	}

	public void getBallOutHand()
	{
		Instance<Ball>.instance.getBallOutHand();
		Instance<AudioController>.instance.play(AudioType.Sound_whistle);
	}

	public void freethrow()
	{
		Instance<Ball>.instance.shoot_player.do_freethrow();
	}

	public void playDribbleSound()
	{
		Instance<AudioController>.instance.play(AudioType.Sound_ball_dribble);
	}
}
